package com.ruoyi.web.controller.pc;

import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.business.domain.WmsInventoryPlanDetail;
import com.ruoyi.business.service.IWmsInventoryPlanDetailService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 盘点计划货物信息Controller
 *
 * @author ruoyi
 * @date 2024-01-21
 */
@RestController
@RequestMapping("/business/inventoryPlanDetail")
public class WmsInventoryPlanDetailController extends BaseController
{
    @Autowired
    private IWmsInventoryPlanDetailService wmsInventoryPlanDetailService;

    /**
     * 查询盘点计划货物信息列表
     */
    @GetMapping("/list")
    public TableDataInfo list(WmsInventoryPlanDetail wmsInventoryPlanDetail)
    {
        startPage();
        List<WmsInventoryPlanDetail> list = wmsInventoryPlanDetailService.selectWmsInventoryPlanDetailList(wmsInventoryPlanDetail);
        return getDataTable(list);
    }

    /**
     * 查询盘点计划货物信息列表query
     */
    @GetMapping("/query")
    public AjaxResult query(WmsInventoryPlanDetail wmsInventoryPlanDetail)
    {
        List<WmsInventoryPlanDetail> list = wmsInventoryPlanDetailService.selectWmsInventoryPlanDetailList(wmsInventoryPlanDetail);
        return AjaxResult.success(list);
    }

//    /**
//     * 导出盘点计划货物信息列表
//     */
//    @Log(title = "盘点计划货物信息", businessType = BusinessType.EXPORT)
//    @GetMapping("/export")
//    public AjaxResult export(WmsInventoryPlanDetail wmsInventoryPlanDetail)
//    {
//        List<WmsInventoryPlanDetail> list = wmsInventoryPlanDetailService.selectWmsInventoryPlanDetailList(wmsInventoryPlanDetail);
//        ExcelUtil<WmsInventoryPlanDetail> util = new ExcelUtil<WmsInventoryPlanDetail>(WmsInventoryPlanDetail.class);
//        return util.exportExcel(list, "盘点计划货物信息数据");
//    }

    /**
     * 获取盘点计划货物信息详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(wmsInventoryPlanDetailService.selectWmsInventoryPlanDetailById(id));
    }

    /**
     * 新增盘点计划货物信息
     */
    @Log(title = "盘点计划货物信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WmsInventoryPlanDetail wmsInventoryPlanDetail)
    {
        wmsInventoryPlanDetail.setCreateBy(getUsername());
        return toAjax(wmsInventoryPlanDetailService.insertWmsInventoryPlanDetail(wmsInventoryPlanDetail));
    }

    /**
     * 修改盘点计划货物信息
     */
    @Log(title = "盘点计划货物信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WmsInventoryPlanDetail wmsInventoryPlanDetail)
    {
        wmsInventoryPlanDetail.setUpdateBy(getUsername());
        return toAjax(wmsInventoryPlanDetailService.updateWmsInventoryPlanDetail(wmsInventoryPlanDetail));
    }

    /**
     * 删除盘点计划货物信息
     */
    @Log(title = "盘点计划货物信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(wmsInventoryPlanDetailService.deleteWmsInventoryPlanDetailByIds(ids));
    }
}
